package net.minecraft.src;

import codechicken.wirelessredstone.core.*;
import net.minecraft.client.Minecraft;
import net.minecraft.src.forge.MinecraftForge;

public class mod_WirelessRedstoneCore extends BaseModMp
{	
	public void ModsLoaded()
    {
		super.ModsLoaded();
		ModLoader.SetInGameHook(this, true, true);
		
		Packet.addIdClassMapping(SaveManager.config().getTag("core.packet.id").getIntValue(235), true, true, PacketRedstoneEther.class);
        PacketRedstoneEther.assignHandler(new int[]{1,19}, new CorePacketHandler());        
		MinecraftForge.registerSaveHandler(RedstoneEtherSaveHandler.getInstance());	
    }
	
	private static void init()
	{
		ConfigTag coreconfig = SaveManager.config().getTag("core").useBraces().setPosition(10);
		ConfigTag itemconfig = coreconfig.getTag("item").useBraces();
		
		RedstoneEther.init();
		
		obsidianStick = new ItemCustomTexture(itemconfig.getTag("obsidianStick.id").getIntValue(6150), 0, texfile).setItemName("obsidianStick");
		stoneBowl = new ItemCustomTexture(itemconfig.getTag("stoneBowl.id").getIntValue(6151), 1, texfile).setItemName("stoneBowl");
		retherPearl = new ItemCustomTexture(itemconfig.getTag("retherPearl.id").getIntValue(6152), 2, texfile).setItemName("retherPearl");
		wirelessTransceiver = new ItemCustomTexture(itemconfig.getTag("wirelessTransceiver.id").getIntValue(6153), 3, texfile).setItemName("wirelessTransceiver");
		powerfulTransceiver = new ItemCustomTexture(itemconfig.getTag("powerfulTransceiver.id").getIntValue(6154), 4, texfile).setItemName("powerfulTransceiver");
		satelliteDish = new ItemCustomTexture(itemconfig.getTag("satelliteDish.id").getIntValue(6155), 5, texfile).setItemName("satelliteDish");
		netherrackStick = new ItemCustomTexture(itemconfig.getTag("netherrackStick.id").getIntValue(6156), 6, texfile).setItemName("netherrackStick");
		blazeRod = new ItemCustomTexture(113, 7, texfile).setItemName("blazeRod");
		
		addRecipies();
		addNames();
	}
	
	private static void addRecipies()
	{
		CraftingManager.getInstance().addRecipe(new ItemStack(obsidianStick), new Object[]{
			"O", 
			"O", 
			Character.valueOf('O'), Block.obsidian});
		CraftingManager.getInstance().addRecipe(new ItemStack(stoneBowl), new Object[]{
			"S S", 
			" S ", 
			Character.valueOf('S'), Block.stone});
		CraftingManager.getInstance().addRecipe(new ItemStack(retherPearl), new Object[]{
			"rgr", 
			"gpg", 
			"rgr", 
			Character.valueOf('r'), Item.redstone, 
			Character.valueOf('g'), Item.lightStoneDust, 
			Character.valueOf('p'), Item.enderPearl});
		CraftingManager.getInstance().addRecipe(new ItemStack(retherPearl), new Object[]{
			"grg", 
			"rpr", 
			"grg", 
			Character.valueOf('r'), Item.redstone, 
			Character.valueOf('g'), Item.lightStoneDust, 
			Character.valueOf('p'), Item.enderPearl});
		CraftingManager.getInstance().addRecipe(new ItemStack(wirelessTransceiver), new Object[]{
			"r", 
			"o", 
			Character.valueOf('r'), retherPearl,
			Character.valueOf('o'), obsidianStick});
		CraftingManager.getInstance().addRecipe(new ItemStack(powerfulTransceiver), new Object[]{
			"r", 
			"b", 
			Character.valueOf('r'), retherPearl,
			Character.valueOf('b'), blazeRod});
		CraftingManager.getInstance().addRecipe(new ItemStack(satelliteDish), new Object[]{
			"t", 
			"b", 
			Character.valueOf('t'), wirelessTransceiver,
			Character.valueOf('b'), stoneBowl});
		CraftingManager.getInstance().addRecipe(new ItemStack(netherrackStick), new Object[]{
			"N", 
			"N", 
			Character.valueOf('N'), Block.netherrack});
		CraftingManager.getInstance().addRecipe(new ItemStack(blazeRod), new Object[]{
			"gl", 
			"ng", 
			Character.valueOf('g'), Item.lightStoneDust,
			Character.valueOf('n'), netherrackStick,
			Character.valueOf('l'), Item.bucketLava});
	}
	
	private static void addNames()
	{
		CoreProxy.AddLocalization("item.obsidianStick.name", "Obsidian Stick");
		CoreProxy.AddLocalization("item.stoneBowl.name", "Stone Bowl");
		CoreProxy.AddLocalization("item.retherPearl.name", "REther Pearl");
		CoreProxy.AddLocalization("item.wirelessTransceiver.name", "Wireless Transceiver");
		CoreProxy.AddLocalization("item.powerfulTransceiver.name", "Powerful Transceiver");
		CoreProxy.AddLocalization("item.satelliteDish.name", "Receiver Dish");
		CoreProxy.AddLocalization("item.netherrackStick.name", "Netherrack Stick");
		CoreProxy.AddLocalization("item.blazeRod.name", "Blaze Rod");
	}
	
	public String Version()
	{
		return "CBE 1.0.0";
	}
	
	public boolean OnTickInGame(Minecraft mc)
	{
		RedstoneEther.tick(mc.theWorld);
		return true;
	}

	public static Item obsidianStick;
	public static Item stoneBowl;
	public static Item retherPearl;
	public static Item wirelessTransceiver;
	public static Item powerfulTransceiver;
	public static Item satelliteDish;
	public static Item netherrackStick;
	public static Item blazeRod;
	
	public static final String texfile = "/codechicken/wirelessredstone/core/wireless1.png";
	
	static
	{
		init();
	}
}
